#!/bin/bash

param_values="1.00e-09 1.33e-09 1.77e-09 2.36e-09 3.16e-09 4.21e-09 5.62e-09 7.50e-09
              1.00e-08 1.33e-08 1.77e-08 2.36e-08 3.16e-08 4.21e-08 5.62e-08 7.50e-08
              1.00e-07 1.33e-07 1.77e-07 2.36e-07 3.16e-07 4.21e-07 5.62e-07 7.50e-07
              1.00e-06 1.33e-06 1.77e-06 2.36e-06 3.16e-06 4.21e-06 5.62e-06 7.50e-06
              1.00e-05 1.33e-05 1.77e-05 2.36e-05 3.16e-05 4.21e-05 5.62e-05 7.50e-05
              1.00e-04 1.33e-04 1.77e-04 2.36e-04 3.16e-04 4.21e-04 5.62e-04 7.50e-04
              1.00e-03 1.33e-03 1.77e-03 2.36e-03 3.16e-03 4.21e-03 5.62e-03 7.50e-03
              1.00e-02 1.33e-02 1.77e-02 2.36e-02 3.16e-02 4.21e-02 5.62e-02 7.50e-02
              1.00e-01 1.33e-01 1.77e-01 2.36e-01 3.16e-01 4.21e-01 5.62e-01 7.50e-01
              1.00e+00 1.33e+00 1.77e+00 2.36e+00 3.16e+00 4.21e+00 5.62e+00 7.50e+00
              1.00e+01 1.33e+01 1.77e+01 2.36e+01 3.16e+01 4.21e+01 5.62e+01 7.50e+01"

param_values="1.00e-04 1.33e-04 1.77e-04 2.36e-04 3.16e-04 4.21e-04 5.62e-04 7.50e-04
              1.00e-03 1.33e-03 1.77e-03 2.36e-03 3.16e-03 4.21e-03 5.62e-03 7.50e-03
              1.00e-02 1.33e-02 1.77e-02 2.36e-02 3.16e-02 4.21e-02 5.62e-02 7.50e-02
              1.00e-01 1.33e-01 1.77e-01 2.36e-01 3.16e-01 4.21e-01 5.62e-01 7.50e-01
              1.00e+00 1.33e+00 1.77e+00 2.36e+00 3.16e+00 4.21e+00 5.62e+00 7.50e+00
              1.00e+01 1.33e+01 1.77e+01 2.36e+01 3.16e+01 4.21e+01 5.62e+01 7.50e+01"

#param_values="000032 000128 000512 002048 008192 032768"

for param in ${param_values}
 do

cat > run-series-input.in << EOF
&input

! output file name
in_basename = 'XXX--${param}'
!in_basename = 'SQZ-P1-5unstr--${param}'
!in_basename = 'SQZ-bubble-${param}'

! test case, method and grid
in_testname = 'squeeze'
! degrees for velocity, bubble (negative is none) and pressure
ku = 1
kb = -1
kp = 1
pressure_stabilization = .true.
!pressure_stabilization = .false.
p_stab_coeff = ${param}
!grid_file = './../GRIDS/2d/squeeze-unstr_000026el.octxt'
!grid_file = './../GRIDS/2d/squeeze-unstr_000102el.octxt'
!grid_file = './../GRIDS/2d/squeeze-unstr_000456el.octxt'
!grid_file = './../GRIDS/2d/squeeze-unstr_001744el.octxt'
!grid_file = './../GRIDS/2d/squeeze-unstr_006952el.octxt'
grid_file = './../GRIDS/2d/squeeze-unstr_027976el.octxt'

!grid_file = './../GRIDS/2d/squeeze_${param}el.octxt'
!grid_file = './../GRIDS/2d/squeeze_000032el.octxt'
!grid_file = './../GRIDS/2d/squeeze_000128el.octxt'
!grid_file = './../GRIDS/2d/squeeze_000512el.octxt'
!grid_file = './../GRIDS/2d/squeeze_002048el.octxt'
!grid_file = './../GRIDS/2d/squeeze_008192el.octxt'
!grid_file = './../GRIDS/2d/squeeze_032768el.octxt'
!grid_file = './../GRIDS/2d/squeeze_131072el.octxt'

!grid_file = './../GRIDS/3d/squeeze_000096el.octxt'
!grid_file = './../GRIDS/3d/squeeze_000768el.octxt'
!grid_file = './../GRIDS/3d/squeeze_006144el.octxt'
!write_grid = .true.
write_grid = .false.
!write_sys = .true.
write_sys = .false.

! number of boundary regions (i.e. number of columns in cbc_type) and
! boundary region -> boundary condition: see mod_bcs.f90
!  first row:
!   1 -> Dirichlet
!   2 -> Neumann (Robin)
!  second row:
!   for Dirichlet:
!    1 -> strong enforcement of the boundary datum on lambda
!   for Neumann:
!    1 -> "Hughes flux", variable lambda
!
! 1D
!nbound = 2
!! side ind:  1   2
!cbc_type = ' 1 , 1 ,
!             1 , 1 '
! 2D
nbound = 4
! side ind:  1   2   3   4
cbc_type = ' 1 , 1 , 1 , 1 ,
             1 , 1 , 1 , 1 '
! 3D
!nbound = 6
!! side ind:  1   2   3   4   5   6
!cbc_type = ' 1 , 1 , 1 , 1 , 1 , 1 ,
!             1 , 1 , 1 , 1 , 1 , 1 '
add_div_lagmultiplier = .true.
!add_div_lagmultiplier = .false.

! linear solver: implemented gmres and umfpack
linsolver = 'umfpack'
!linsolver = 'gmres'

! UMFPACK control variables
umfpack_print_level = 0

! GMRES control variables
gmres_abstol = .true.
gmres_toll = 1e-30
!gmres_toll = 1e-9
!preconditioner = 'none'
!preconditioner = 'diagonal'
!preconditioner = 'tridiagonal'
preconditioner = 'multidiagonal'
!precon_ndiags = 2000 ! only used if preconditioner='multidiagonal'
precon_ndiags = -1 ! use the whole matrix
initial_guess_umfpack = .true. ! use umfpack to get the first guess
!initial_guess_umfpack = .false.

! error norms
compute_error_norms = .true.
!compute_error_norms = .false.
err_extra_deg = 1 ! additional accuracy in the error computation
/
EOF

 if [ -h "cg-stokes.in" ]
  then
   unlink cg-stokes.in
 fi
 ln -s run-series-input.in cg-stokes.in

 ./../bin/cg-stokes

done
